package com.aurora.source.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aurora.source.R;
import com.aurora.source.authority.activity.CreateYardActivity;
import com.aurora.source.authority.bean.CommodityManagementBean;
import com.aurora.source.base.BaseRecyclerAdapter;
import com.aurora.source.base.CommonHolder;

import butterknife.BindView;

public class CommodityManagementAdapter extends BaseRecyclerAdapter<CommodityManagementBean.ProductResponseModelListBean> {
    @Override
    public CommonHolder<CommodityManagementBean.ProductResponseModelListBean> setViewHolder(ViewGroup parent) {
        return new MyHolder(parent.getContext(), parent);
    }

    class MyHolder extends CommonHolder<CommodityManagementBean.ProductResponseModelListBean> {

        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_create)
        TextView tvCreate;
        Context context;

        public MyHolder(Context context, ViewGroup root) {
            super(context, root, R.layout.item_commodity_management);
            this.context = context;
        }

        @Override
        public void bindData(final CommodityManagementBean.ProductResponseModelListBean commodityManagementBean, int positon) {
            tvTitle.setText(commodityManagementBean.getProductName());
            tvTime.setText(commodityManagementBean.getCreateTime()+"");
            tvCreate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getContext(), CreateYardActivity.class);
                    intent.putExtra("traceabilityCode",commodityManagementBean.getTraceabilityCode());
                    intent.putExtra("productName",commodityManagementBean.getProductName());
                    context.startActivity(intent);
                }
            });
        }
    }
}
